package com.ciwong.epaper.modules.epaper.ui.newlistenspeak.shortcoversation.fragment;


import android.media.MediaPlayer;
import android.media.PlaybackParams;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.View;

import com.ciwong.epaper.R;
import com.ciwong.epaper.application.EApplication;
import com.ciwong.epaper.modules.epaper.bean.Attachments;
import com.ciwong.epaper.modules.epaper.bean.ModuleSet;
import com.ciwong.epaper.modules.epaper.bean.OptionDetail;
import com.ciwong.epaper.modules.epaper.bean.QuestionRule;
import com.ciwong.epaper.modules.epaper.bean.Questions;
import com.ciwong.epaper.modules.epaper.bean.ResourceDetail;
import com.ciwong.epaper.modules.epaper.ui.newlistenspeak.LsBottomView;
import com.ciwong.epaper.modules.epaper.util.ListenSpeakUtil;
import com.ciwong.epaper.util.EConstants;
import com.ciwong.epaper.util.ESystem;
import com.ciwong.libs.audio.play.AudioPlayer;
import com.ciwong.libs.utils.CWLog;
import com.ciwong.libs.utils.CWSys;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;


/**
 * date :2018/5/3
 * author: loco
 * description:
 * version:
 * email: lzh838330255@163.com
 */

public abstract class ShortConversationFragment extends BaseConversationFragment {

    private ListenSpeakUtil.State status;

    private int playCount;//播放的次数
    private int PLAY_POSITION = 0;
    private int mSmallQuesIndex;//播放的小题题号
    private int timeCount = 0;// 递减计时(秒)
    private int mReadTime = 0; //阅题时间，用于第一次提示语是否展示的条件
    private int mProgress;//底部计时器 进度
    protected int workTime;// 用时(秒)
    protected int mReadyTime = 0;//准备时间
    protected boolean mAheadRecord = false; //提前完成录音
    protected ArrayList<Boolean> isDoRecords = new ArrayList<>();// 是否做过的记录
    //做题记录
    protected String uuid = UUID.randomUUID().toString();
    protected boolean isPlayAgain = false;// 是否是再一次播放

    /**
     * 开始播放音频文件(流程开始入口)
     */
    protected void startPlayQuestion(View view) {
        initListener(view);
        //加载题干
        setData(mResourceDetail.getTemplateSettings(), null);
        //开始播放大题
        if (mIsPlayStartExamAduio) {
            status = ListenSpeakUtil.State.START;
            AudioPlayer.getInstance().play(ListenSpeakUtil.SoundUrl.SOUND_START_EXAM, mActivity, null);
        } else {
            startLoadBigQuestion(mResourceDetail);
        }
    }

    @Override
    protected void onSkipClick() {
        // 计时结束
        switch (status) {
            case BIG_QUESTION_STEM:
                AudioPlayer.getInstance().stop();
                break;
            default:
                removeHandlerMsg(ListenSpeakUtil.HandlerWhat.UPDATE_TIME, mHandler);
                mAheadRecord = true;
                onTimeOver(status);
                break;
        }
    }

    @Override
    protected void onHandleMessage(int msgType) {
        switch (msgType) {
            case ListenSpeakUtil.HandlerWhat.TOTAL_TIMER:// 总计时
                workTime = workTime + 1;
                removeHandlerMsg(ListenSpeakUtil.HandlerWhat.TOTAL_TIMER, mHandler);
                //这里逻辑有问题啊
                if (workTime > 0) {
                    mHandler.sendEmptyMessageDelayed(ListenSpeakUtil.HandlerWhat.TOTAL_TIMER, 1000);
                }
                break;
            case ListenSpeakUtil.HandlerWhat.UPDATE_TIME:// 倒计时更新时间 （准备时间倒计时，阅题倒计时，答题（录音）倒计时）
                // 递减计时
                if (timeCount > 0) {
                    timeCount--;
                    mProgress++;
                    mHandler.removeMessages(ListenSpeakUtil.HandlerWhat.UPDATE_TIME);
                    int strResId = -1;
                    switch (status) {
                        case LOOK_SMALL_QUESTION:// 小题阅题
                            //                            if ()

                            strResId = R.string.look_question;
                            break;
                        case READY_SMALL_QUESTION:// 小题准备
                            strResId = R.string.ready_read;
                            break;
                        case ANSWER:
                            //选择题、填空题 答题倒计时
                            strResId = R.string.answer_question;
                        default:
                            break;
                    }
                    if (strResId > 0) {
                        mHandler.sendEmptyMessageDelayed(ListenSpeakUtil.HandlerWhat.UPDATE_TIME, 1000);
                        Spannable span = new SpannableString(getString(R.string.tip_timer2, getString(strResId), String.valueOf(timeCount)));
                        span.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.color_light_green)), span.toString().indexOf("余") + 1, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                        boolean isLastQues = false;
                        int skipType = LsBottomView.SKIP_TYPE_COUNT_DOWN;
                        if (strResId == R.string.answer_question) {
                            if (mActivity != null) {
                                isLastQues = mActivity.isLastQuestion(mResourceDetail, mSmallQuesIndex);
                            }
                            skipType = LsBottomView.SKIP_TYPE_CHOICE;
                        }
                        timeUpdate(span, mProgress, true, skipType, status, isLastQues);
                    }
                } else {// 计时结束
                    removeHandlerMsg(ListenSpeakUtil.HandlerWhat.UPDATE_TIME, mHandler);
                    mAheadRecord = false;
                    try {
                        onTimeOver(status);
                    } catch (NullPointerException e) {
                        e.printStackTrace();
                    }
                }
                break;

            default:
                break;
        }
    }


    @Override
    protected void onPlayerStop(Object audioUrl) {
        CWLog.d(TAG, "播放结束，status=" + status + "----infoRetail");
        onPlayStop(false, View.INVISIBLE);
        switch (status) {
            case START:// 开始
                //开始播放大题音频
                startLoadBigQuestion(mResourceDetail);
                break;
            case BIG_QUESTION_STEM:// 单个大题题干音频播放完毕（重复播放同一音频）
                CWLog.d("BIG_QUESTION_STEM:", "结束！！！");
                CWSys.setSharedBoolean(EConstants.SHARE_KEY_LSW_TIPS_PLAY + mActivity.getUserInfoBase().getUserId(), true);
                onBigStemPlayOver(mResourceDetail);
                break;
            case SMALL_QUESTION_STEM:// 单个小题题干播放完毕(连续播放附件内的音频)
                timeEnd();
                // 播放计数
                playCount--;
                if (playCount > 0) {
                    isPlayAgain = true;
                    isShowTime = false;// 间隔时间内不需要显示倒计时
                    Message msg = new Message();
                    // 播放音频
                    msg.what = ListenSpeakUtil.HandlerWhat.PLAY_SOUND;
                    msg.obj = audioUrl;
                    mActivity.mRecorderHandler.sendMessageDelayed(msg, 2000);// 播放附件音频
                } else {
                    isPlayAgain = false;
                    playCount = mProgress = 0;
                    // 播放小题音频
                    if (status == ListenSpeakUtil.State.SMALL_QUESTION_STEM) {
                        QuestionRule listeningAndSpeakingRule = mResourceDetail.getTemplateSettings().getListeningAndSpeakingRule();
                        //题目类型:阅读理解题
                        startReady(listeningAndSpeakingRule.getReadyTime(), true);
                    }
                }
                break;
            case ANSWER:// 开始答题音频播放完毕
                Log.d(TAG, "#########允许开始答题########");
                timeCount = mResourceDetail.getTemplateSettings().getListeningAndSpeakingRule().getAnswerTime();// 取得答题时间
                timeStart(timeCount);
                startRecordTimeCount();
                break;
            case END_AUDIO:// 音频播放完毕
                startSwitchNextQuestion(mResourceDetail);
                break;
            case END:// 若是最后一大题的最后一小题，考生结束
                CWLog.d(TAG, "END-提交答案");
                toSubmitAnswer();
                break;
            default:
                break;
        }
    }

    @Override
    protected void onPlayerPlaying(long duration, long progress) {
        int remainCount;
        Spannable span;
        switch (status) {
            case BIG_QUESTION_STEM:
                // 更新时间
                remainCount = (int) (duration - progress) / 1000;
                span = new SpannableString(getString(R.string.tip_timer2, getString(isPlayAgain ? R.string.tip_play_again : R.string.tip_play), remainCount + ""));
                span.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.color_light_green)), span.toString().indexOf("余") + 1, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                timeUpdate(span, mProgress, true, LsBottomView.SKIP_TYPE_PLAY_STEM, status, false);
                break;
            case SMALL_QUESTION_STEM:
                mProgress = (int) progress;
                timeStart((int) duration);
                if (mActivity.isShowTime) {
                    // 更新时间
                    remainCount = (int) (duration - progress) / 1000;
                    span = new SpannableString(getString(R.string.tip_timer2, getString(isPlayAgain ? R.string.tip_play_again : R.string.tip_play), remainCount + ""));
                    span.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.color_light_green)), span.toString().indexOf("余") + 1, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    timeUpdate(span, mProgress, false, LsBottomView.SKIP_TYPE_NULL, status, false);

                }
                break;
            default:
                break;
        }
    }

    @Override
    protected void onPlayerError(int arg0, Object arg1) {

    }

    //做题总计时
    private void startTotalCount() {
        mHandler.sendEmptyMessage(ListenSpeakUtil.HandlerWhat.TOTAL_TIMER);//开始计时
    }

    protected void startRecordTimeCount() {
        //录音倒计时
        removeHandlerMsg(ListenSpeakUtil.HandlerWhat.UPDATE_TIME, mHandler);
        mHandler.sendEmptyMessage(ListenSpeakUtil.HandlerWhat.UPDATE_TIME);
    }

    /**
     * 开始播放大题音频
     * // 进入播放大题题干状态
     *
     * @param resourceDetail
     */
    private void startLoadBigQuestion(ResourceDetail resourceDetail) {
        //总计时开始
        startTotalCount();
        // 进入播放大题题干状态
        status = ListenSpeakUtil.State.BIG_QUESTION_STEM;
        printState();
        // 进入播放大题题干状态
        if (resourceDetail != null) {
            ModuleSet moduleSet = resourceDetail.getTemplateSettings();
            //用户可选择设置可以选择不播放大题题干
            if (mActivity != null && mActivity.isReadBigQuestionStem) {
                checkHeighlightPosition(PLAY_POSITION);
                //大题题干高亮
                AudioPlayer.getInstance().play(ESystem.formatPath(moduleSet.getAudioUrl()));// 大题题干音频
                try {
                    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M && EApplication.getInstance().mPlayerspeed != 1.0f) {
                        MediaPlayer mMediaPlayer = AudioPlayer.getInstance().getMediaPlayer();
                        if (mMediaPlayer != null) {
                            try {
                                PlaybackParams params = mMediaPlayer.getPlaybackParams().setSpeed(EApplication.getInstance().mPlayerspeed);
                                if (params != null) {
                                    mMediaPlayer.setPlaybackParams(params);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                showPlayButton(Questions.QuestionType.QUESTION_TYPE_CHOICE);
                //                lsBottomView.showPlayButton(Questions.QuestionType.QUESTION_TYPE_CHOICE);
                CWLog.d("isReadBigQuestionStem:", "结束！！！");
            } else {
                CWLog.d("isReadBigQuestionStem else:", "结束！！！");
                onBigStemPlayOver(resourceDetail);
            }
        }
    }

    private void onBigStemPlayOver(ResourceDetail resourceDetail) {
        playCount = 0;
        mSmallQuesIndex = 0;
        //题干不高亮，内容高亮
        CWLog.d("onBigStemPlayOver:", "结束！！！");
        setData(resourceDetail.getTemplateSettings(), resourceDetail.getQuestions());
        checkHeighlightPosition(mSmallQuesIndex + 1);
        //1 信息转述 2 自主提问 3 视频朗读
        Questions questions = null;
        if (null != resourceDetail.getQuestions() && mSmallQuesIndex < resourceDetail.getQuestions().size()) {
            questions = resourceDetail.getQuestions().get(mSmallQuesIndex);
        }
        startCheckSmallQuestion(resourceDetail, questions, false);
    }

    /**
     * 开始选中小题题干和附件
     *
     * @param resourceDetail
     * @param question
     * @param isFromLook
     */
    private void startCheckSmallQuestion(ResourceDetail resourceDetail, Questions question, boolean isFromLook) {
        status = isFromLook ? ListenSpeakUtil.State.SMALL_QUESTION_STEM : ListenSpeakUtil.State.LOOK_SMALL_QUESTION;
        OptionDetail optionsDetail = question.getTrunk();
        // (当类型为5的时候，root开头的那3个字段才有用)
        QuestionRule listeningAndSpeakingRule = resourceDetail.getTemplateSettings().getListeningAndSpeakingRule();
        //是否是阅读理解题
        int lookTime = 0;
        if (listeningAndSpeakingRule != null)
            lookTime = listeningAndSpeakingRule.getLookTime();// 取得阅题时间
        if (isFromLook) {
            int audioViews = listeningAndSpeakingRule.getAudioViews();// 音频播放次数
            int readyTime = listeningAndSpeakingRule.getReadyTime();
            startLoadAttachments(optionsDetail, audioViews, lookTime, readyTime, isFromLook, true);
        } else {
            startLookQuestion(lookTime);
        }
    }

    /**
     * 开始阅题
     */
    private void startLookQuestion(int lookTime) {
        playCount = 0;
        mProgress = 0;
        // 进入阅题状态
        timeCount = lookTime;
        mReadTime = lookTime;
        printState();
        timeStart(timeCount);
        removeHandlerMsg(ListenSpeakUtil.HandlerWhat.UPDATE_TIME, mHandler);
        mHandler.sendEmptyMessage(ListenSpeakUtil.HandlerWhat.UPDATE_TIME);
    }

    /**
     * 播放附件里的语音
     * 播放第一个附件音频
     */
    private void loadAttachmentsAudio(int audioViews, List<String> audioUrlList) {
        playCount = audioViews;
        showPlayButton(Questions.QuestionType.QUESTION_TYPE_CHOICE);
        isPlayAgain = false;
        AudioPlayer.getInstance().play(audioUrlList.get(0));// 播放第一个附件音频
        try {
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M && EApplication.getInstance().mPlayerspeed != 1.0f) {
                MediaPlayer mMediaPlayer = AudioPlayer.getInstance().getMediaPlayer();
                if (mMediaPlayer != null) {
                    try {
                        PlaybackParams params = mMediaPlayer.getPlaybackParams().setSpeed(EApplication.getInstance().mPlayerspeed);
                        if (params != null) {
                            mMediaPlayer.setPlaybackParams(params);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        checkHeighlightPosition(mSmallQuesIndex + 1);
    }

    private void onTimeOver(ListenSpeakUtil.State timeOverType) {
        //准备时间结束
        mProgress = timeCount = 0;
        timeEnd();
        List<Questions> smallQuesList = mResourceDetail.getQuestions();
        // 当前状态   这个是状态值 //.UPDATE_TIME:// 更新时间 加上更新时间这个操作  才会走
        timeOverForNextTip(View.INVISIBLE);
        switch (timeOverType) {
            case LOOK_SMALL_QUESTION:// 小题阅题结束
                //当阅题时间或者准备时间为0时，下一次还要展示引导提示语
                if (mReadTime > 0) {
                    CWSys.setSharedBoolean(EConstants.SHARE_KEY_LSW_TIPS_READ + mActivity.getUserInfoBase().getUserId(), true);
                }
                Questions smallQuestion = smallQuesList.get(mSmallQuesIndex);
                CWLog.d(TAG, "------小题阅读结束-------infoRetail-------");
                startCheckSmallQuestion(mResourceDetail, smallQuestion, true);
                break;
            case READY_SMALL_QUESTION:// 小题答题准备倒计时结束
                Log.d("bottomview", "############小题准备倒计时结束 ############mReadyTime##" + mReadyTime);
                if (mReadyTime > 0) {
                    CWSys.setSharedBoolean(EConstants.SHARE_KEY_LSW_TIPS_PREPARE + mActivity.getUserInfoBase().getUserId(), true);
                }
                startAnswerQuestion();
                break;
            case ANSWER:// 答题结束
                CWSys.setSharedBoolean(EConstants.SHARE_KEY_LSW_TIPS_ANSWER + mActivity.getUserInfoBase().getUserId(), true);
                timeOverForAnswer(View.VISIBLE, false, -1);
                //提前结束答题不需要提示语
                if (mAheadRecord) {
                    mAheadRecord = false;
                    startSwitchNextQuestion(mResourceDetail);
                } else {
                    status = ListenSpeakUtil.State.END_AUDIO;
                    // 答题结束提示语
                    AudioPlayer.getInstance().play(ListenSpeakUtil.SoundUrl.SOUND_END_ANSWER, mContext, null);
                }
                break;
        }
    }


    /**
     * 开始准备倒计时
     * 发送更新时间消息
     *
     * @param readyTime
     * @param isSmallReady
     */
    private void startReady(int readyTime, boolean isSmallReady) {
        playCount = 0;
        status = isSmallReady ? ListenSpeakUtil.State.READY_SMALL_QUESTION : ListenSpeakUtil.State.READY_CHILD_QUESTION;
        // 进入准备状态
        printState();
        timeCount = readyTime;
        mReadyTime = readyTime;
        mProgress = 0;
        timeStart(timeCount);
        removeHandlerMsg(ListenSpeakUtil.HandlerWhat.UPDATE_TIME, mHandler);
        mHandler.sendEmptyMessage(ListenSpeakUtil.HandlerWhat.UPDATE_TIME);
    }

    /**
     * 开始切换到下一题
     *
     * @param resourceDetail
     */
    private void startSwitchNextQuestion(ResourceDetail resourceDetail) {
        Log.d(TAG, "#########切题 关闭选择题可答题#########");
        //当前层级，是否有小题，小题是否遍历完，大题遍历
        if (mActivity.isFinishing()) {
            return;
        }
        List<Questions> smallQuesList = resourceDetail.getQuestions();
        if (smallQuesList != null && mSmallQuesIndex < smallQuesList.size() - 1) {// 下一小题
            mSmallQuesIndex++;
            //题干不高亮，内容高亮
            checkHeighlightPosition(mSmallQuesIndex + 1);
            Questions smallQues = smallQuesList.get(mSmallQuesIndex);
            if (!ListenSpeakUtil.questionTypeIsExist(smallQues.getType())) {
                mActivity.showToastError(R.string.question_type_not_exist);
                startSwitchNextQuestion(resourceDetail);
                return;
            }
            // (当类型为5的时候，root开头的那3个字段才有用)
            QuestionRule listeningAndSpeakingRule = resourceDetail.getTemplateSettings().getListeningAndSpeakingRule();
            int lookTime = listeningAndSpeakingRule.getLookTime();// 取得阅题时间
            status = ListenSpeakUtil.State.LOOK_SMALL_QUESTION;
            startLookQuestion(lookTime);
        } else {
            //            releaseLsBottomView();
            if (mLsMode == ListenSpeakUtil.LsMode.RETRY_MODE) {
                mActivity.setResultAnswer(mLswAnswerList, mBigQuesIndex + 1, false, false, true,totalQuesIndex);
                return;
            } else {// 结束短对话，或者结束考试（若本大题是最后一个大题）
                if (mActivity.isFinishing()) {
                    return;
                }
                mHandler.removeMessages(ListenSpeakUtil.HandlerWhat.TOTAL_TIMER);
                if (mBigQuesIndex == mTotalCount - 1) {
                    status = ListenSpeakUtil.State.END;
                    AudioPlayer.getInstance().play(ListenSpeakUtil.SoundUrl.SOUND_END_EXAM, mContext, null);
                } else {
                    mActivity.setResultAnswer(mLswAnswerList, mBigQuesIndex + 1, false, false, true,totalQuesIndex);
                }
            }
        }
    }

    /**
     * 开始答题
     */
    private void startAnswerQuestion() {
        try {
            status = ListenSpeakUtil.State.ANSWER;
            printState();
            // 进入答题状态
            AudioPlayer.getInstance().play(ListenSpeakUtil.SoundUrl.SOUND_START_ANSWER, mContext, null);
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }

    /**
     * 开始加载附件
     *
     * @param optionsDetail
     * @param audioViews    音频播放次数
     * @param lookTime      看题时间
     * @param readyTime     准本时间
     * @param isFromLook    是否来自
     * @param isSmallReady  是否来自
     */
    private void startLoadAttachments(OptionDetail optionsDetail, int audioViews, int lookTime, int readyTime, boolean isFromLook, boolean isSmallReady) {
        // 取附件集合
        final List<Attachments> attachmentsList = optionsDetail
                .getAttachments();
        List<String> audioUrlList = new ArrayList<String>();
        if (attachmentsList != null && !attachmentsList.isEmpty()) {
            // 取出所有的图片或语音地址
            List<String> imgUrlList = new ArrayList<String>();
            for (int i = 0; i < attachmentsList.size(); i++) {
                Attachments attachments = attachmentsList.get(i);
                if (attachments != null) {
                    String url = attachments.getUrl();
                    if (!TextUtils.isEmpty(url)) {
                        switch (attachments.getFileType()) {
                            case Attachments.AttachmentFileType.ATTACHMENT_FILE_TYPE_IMG:// 图片
                                imgUrlList.add(ESystem.formatPath(url));
                                break;
                            case Attachments.AttachmentFileType.ATTACHMENT_FILE_TYPE_AUDIO:// 语音
                                audioUrlList.add(ESystem.formatPath(url));
                                break;
                        }
                    }
                }
            }
            if (!audioUrlList.isEmpty()) {
                //播放附件里的语音
                loadAttachmentsAudio(audioViews, audioUrlList);
            } else {
                //开始准备倒计时  发送计时消息
                startReady(readyTime, isSmallReady);
            }
        } else {// 没有附件的简答题
            if (isFromLook) {
                startReady(readyTime, isSmallReady);
            } else {
                startLookQuestion(lookTime);
            }
        }
    }

    /**
     * 去提交答案  点击提交作业  和结束提交答案
     */
    private void toSubmitAnswer() {
        isStopHandler = true;
        isStopFlag = true;
        switchRelease(mActivity.mRecorderHandler);
        mActivity.setResultAnswer(mLswAnswerList, mBigQuesIndex + 1, false, false, true,totalQuesIndex);

    }

    /**
     * 切换的时候释放资源
     * 口头作文未开始
     * 显示计时
     * 移除消息队列
     */
    private void switchRelease(Handler mRecorderHandler) {
        mActivity.isShowTime = true;
        if (mHandler != null) {
            mHandler.removeCallbacksAndMessages(null);
            //继续计时
            mHandler.sendEmptyMessage(
                    ListenSpeakUtil.HandlerWhat.TOTAL_TIMER);
        }
        if (mRecorderHandler != null) {
            mRecorderHandler.removeCallbacksAndMessages(null);
        }
        AudioPlayer.getInstance().stop();
    }

    /**
     * 为展示界面 填充数据
     * shortDialogAdapter.setData()
     */
    protected abstract void setData(ModuleSet moduleSet, List<Questions> questionsList);

    /**
     * 选择高亮条目
     * shortDialogAdapter.setHightLight();
     * rvShortConversation.smoothScrollToPosition(mSmallQuesIndex + 1);
     */
    protected abstract void checkHeighlightPosition(int position);

    /**
     * 播放音频展示的bottomView 的 销毁释放
     * lsBottomView.microRecordingSetVisibility(View.GONE);
     * lsBottomView.hideTimerAnimation();
     */
//    protected abstract void releaseLsBottomView();

    /**
     * 播放音频展示的bottomView 的 ??
     * lsBottomView.showPlayButton(Questions.QuestionType.QUESTION_TYPE_CHOICE);
     *
     * @param questionTypeChoice
     */
    protected abstract void showPlayButton(int questionTypeChoice);

    /**
     * 播放音频展示的bottomView 的 计时开始
     * seekBarSetMax(timecount)
     */
    protected abstract void timeStart(int duration);

    /**
     * 播放音频展示的bottomView 的 计时时间变动
     * lsBottomView.updateTimer(span, mProgress, true, LsBottomView.SKIP_TYPE_PLAY_STEM, status, false);
     */
    protected abstract void timeUpdate(CharSequence sequence, int progress, boolean showSkipBtn, int skipType, ListenSpeakUtil.State status, boolean isLastQuestion);

    /**
     * 播放音频展示的bottomView 的 计时结束
     * lsBottomView.hideTimerAnimation();
     */
    protected abstract void timeEnd();

    /**
     * 播放音频展示的bottomView 的 计时结束或者跳过 setNextTipsVisibility(View.INVISIBLE)展示
     * lsBottomView.setNextTipsVisibility(View.INVISIBLE);
     */
    protected abstract void timeOverForNextTip(int visible);

    /**
     * 播放音频展示的bottomView 的 计时结束(答题结束)
     * lsBottomView.setStateBarVisibility(View.VISIBLE);
     */
    protected abstract void timeOverForAnswer(int visible, boolean b, int skipType);

    /**
     * 播放音频展示的bottomView 的 播放结束
     * lsBottomView.setPlayBtnState(false);
     * lsBottomView.setNextTipsVisibility(View.INVISIBLE);
     *
     * @param bool
     * @param invisible
     */
    protected abstract void onPlayStop(boolean bool, int invisible);

    /**
     * 移除Handler消息
     *
     * @param what
     */
    protected void removeHandlerMsg(int what, Handler mHandler) {
        if (mHandler.hasMessages(what)) {
            mHandler.removeMessages(what);
        }
    }

    /**
     * 打印当前状态
     */
    private void printState() {
        CWLog.d(TAG, "state：" + status);
    }
}
